/*
 * HelpCenterPresenter.java
 * business
 *
 * Created by SunDing on 2016/9/9.
 *
 * Copyright (c) 2016年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.service.helpcenter;

import com.yidiandao.business.data.model.CommonModel;
import com.yidiandao.business.data.model.ICommonModel;
import com.yidiandao.business.ui.widget.listview.DisplayListItem;
import com.yidiandao.business.ui.widget.view.SuperLoadingLayout;

import java.util.List;

/** 帮助中心 */
public class HelpCenterPresenter implements HelpCenterContract.Presenter {

    private final CommonModel mCommonModel;
    private HelpCenterContract.View mView;

    public HelpCenterPresenter(HelpCenterContract.View view) {
        mView = view;
        mView.setPresenter(this);
        mCommonModel = new CommonModel();
    }

    @Override
    public void start() {
        mCommonModel.getHelpCenterInfo(
                mView.getPagerTag(),
                new ICommonModel.onAccessNetListener<List<DisplayListItem>>() {

                    @Override
                    public void onSuccess(List<DisplayListItem> displayListItems) {
                        mView.refreshContent(mView.checkResultObject(displayListItems));
                        mView.setDisplayListItem(displayListItems);
                    }

                    @Override
                    public void onFailed() {
                        mView.refreshContent(SuperLoadingLayout.STATE_ERROR);
                    }

                    @Override
                    public void onFinal() {
                    }
                });
    }
}
